import React, { useState, useRef, useEffect } from 'react'

export default function Example() {
  const InputE1 = useRef(null)
  const onButtonClick = () => {
    InputE1.current.value = 'Hello,花城'
  }
  const [text, setText] = useState('jspang')
  const textRef = useRef()
  useEffect(() => {
    textRef.current = text
    console.log('textRef.current:', textRef.current)
  })

  return (
    <>
      <input type="text" ref={InputE1} />
      <button onClick={onButtonClick}>在input上展示文字</button>
      <input type="text" value={text} onChange={e => setText(e.target.value)} />
    </>
  )
}
